//
//  ZYLSearchTableViewCell.m
//  Cartoon
//
//  Created by dllo on 15/7/14.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ZYLSearchTableViewCell.h"
#import "Define.h"
#import "UIImageView+WebCache.h"
@implementation ZYLSearchTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.mainImage = [[[UIImageView alloc] init] autorelease];
        self.cartoonTitle = [[[UILabel alloc] init] autorelease];
        self.cartoonAuthor = [[[UILabel alloc] init] autorelease];
        [self.contentView addSubview:self.mainImage];
        [self.contentView addSubview:self.cartoonTitle];
        [self.contentView addSubview:self.cartoonAuthor];
    }
    return self;
}

- (void)setResultModel:(ZYLSearchResultModel *)resultModel
{
    if (_resultModel != resultModel) {
        [_resultModel release];
        _resultModel = [resultModel retain];
    }
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:resultModel.searchcover_image_url]];
    self.cartoonTitle.text = [resultModel searchtitle];
    self.cartoonAuthor.text = [resultModel searchnickname];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.mainImage.frame = CGRectMake(10, 10, SCREEN_WIDTH / 3.0, self.contentView.frame.size.height - 20);
    self.cartoonTitle.frame = CGRectMake(self.mainImage.frame.origin.x + self.mainImage.frame.size.width + 10, 10, SCREEN_WIDTH / 2.0, 30);
    self.cartoonAuthor.frame = CGRectMake(self.cartoonTitle.frame.origin.x, self.cartoonTitle.frame.origin.y + self.cartoonTitle.frame.size.height + 5, self.cartoonTitle.frame.size.width, 30);
    self.cartoonAuthor.font = [UIFont systemFontOfSize:15];
    self.cartoonAuthor.textColor = [UIColor lightGrayColor];
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
